package com.ruoyi.web.controller.base;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.base.domain.BusWaterSegment;
import com.ruoyi.base.service.IBusWaterSegmentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 基本断面Controller
 * 
 * @author ruoyi
 * @date 2025-07-27
 */
@RestController
@RequestMapping("/base/segment")
public class BusWaterSegmentController extends BaseController
{
    @Autowired
    private IBusWaterSegmentService busWaterSegmentService;

    /**
     * 查询基本断面列表
     */
//    @PreAuthorize("@ss.hasPermi('base:segment:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusWaterSegment busWaterSegment)
    {
        startPage();
        List<BusWaterSegment> list = busWaterSegmentService.selectBusWaterSegmentList(busWaterSegment);
        return getDataTable(list);
    }

    //    @PreAuthorize("@ss.hasPermi('base:segment:listall')")
    @GetMapping("/listall")
    public AjaxResult listall(BusWaterSegment busWaterSegment)
    {
        List<BusWaterSegment> list = busWaterSegmentService.selectBusWaterSegmentList(busWaterSegment);
        return AjaxResult.success(list);
    }

    /**
     * 导出基本断面列表
     */
//    @PreAuthorize("@ss.hasPermi('base:segment:export')")
//    @Log(title = "基本断面", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusWaterSegment busWaterSegment)
    {
        List<BusWaterSegment> list = busWaterSegmentService.selectBusWaterSegmentList(busWaterSegment);
        ExcelUtil<BusWaterSegment> util = new ExcelUtil<BusWaterSegment>(BusWaterSegment.class);
        util.exportExcel(response, list, "基本断面数据");
    }

    /**
     * 获取基本断面详细信息
     */
//    @PreAuthorize("@ss.hasPermi('base:segment:query')")
    @GetMapping(value = "/getinfo/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") String ID)
    {
        return success(busWaterSegmentService.selectBusWaterSegmentByID(ID));
    }

    /**
     * 新增基本断面
     */
//    @PreAuthorize("@ss.hasPermi('base:segment:add')")
//    @Log(title = "基本断面", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody BusWaterSegment busWaterSegment)
    {
        return toAjax(busWaterSegmentService.insertBusWaterSegment(busWaterSegment));
    }

    /**
     * 修改基本断面
     */
//    @PreAuthorize("@ss.hasPermi('base:segment:edit')")
//    @Log(title = "基本断面", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody BusWaterSegment busWaterSegment)
    {
        return toAjax(busWaterSegmentService.updateBusWaterSegment(busWaterSegment));
    }

    /**
     * 删除基本断面
     */
//    @PreAuthorize("@ss.hasPermi('base:segment:remove')")
//    @Log(title = "基本断面", businessType = BusinessType.DELETE)
	@GetMapping("/remove/{IDs}")
    public AjaxResult remove(@PathVariable String[] IDs)
    {
        return toAjax(busWaterSegmentService.deleteBusWaterSegmentByIDs(IDs));
    }
}
